├── 167.two-sum-ii-input-array-is-sorted.py ├── 69.my-sqrt.py ├── 9.is-palindrome.py ├── 67.add-binary.py ├── 136.single-number.py ├── 28.str-str.py ├── 35.search-insert.py ├── 58.length-of-last-word.py ├── 125.valid-palindrome.py ├── 7.reverse.py ├── 70.climb-stairs.py ├── 122.best-time-to-buy-and-sell-stock-ii.pysubmissions ├── 121.best-time-to-buy-and-sell-stock.py ├── 27.remove-element.py ├── 141.linked-list-cycle.py ├── 26.remove-duplicates.py ├── 1.two-sum.py ├── 88.merge.py ├── 119.pascals-triangle-ii.py ├── 6121.query-kth-smallest-trimmed-number.py ├── 118.pascals-triangle ├── 14.longest-common-prefix.py ├── 111.minimum-depth-of-binary-tree.py ├── 13.roman-to-int.py ├── 6122.minimum-deletions-to-make-array-divisible ├── 112.path-sum.py ├── 104.max-depth.py ├── 160.intersection-of-two-linked-lists.py ├── 20.is-valid.py ├── 53.max-sub-array.py ├── 66.plus-one.py ├── README.org ├── 110.is-balanced.py ├── 100.is-same-tree.py ├── 662.maximum-width-of-binary-tree ├── 155.min-stack.py ├── 21.merge-two-lists.py ├── 101.is-symmetric.py ├── 83.delete-duplicates.py ├── .gitignore ├── 107.level-orderbottom.py └── 38.count-and-say.py /167.two-sum-ii-input-array-is-sorted.py: -------------------------------------------------------------------------------- 1 | /two-sum-ii-input-array-is-sorted -------------------------------------------------------------------------------- /69.my-sqrt.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def mySqrt(self, x: int) -> int: 3 | return int(math.sqrt(x)) -------------------------------------------------------------------------------- /9.is-palindrome.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isPalindrome(self, x: int) -> bool: 3 | return str(x) == str(x)[::-1] -------------------------------------------------------------------------------- /67.add-binary.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def addBinary(self, a: str, b: str) -> str: 3 | return bin(int(a, 2) + int(b, 2))[2:] -------------------------------------------------------------------------------- /136.single-number.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def singleNumber(self, nums: List[int]) -> int: 3 | return functools.reduce(operator.xor, nums) 4 | -------------------------------------------------------------------------------- /28.str-str.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def strStr(self, haystack: str, needle: str) -> int: 3 | return haystack.find(needle) if needle in haystack else -1 -------------------------------------------------------------------------------- /35.search-insert.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def searchInsert(self, nums: List[int], target: int) -> int: 3 | return bisect.bisect_left(nums, target) 4 | -------------------------------------------------------------------------------- /58.length-of-last-word.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def lengthOfLastWord(self, s: str) -> int: 3 | return len(splited[-1]) if (splited := s.split()) else 0 -------------------------------------------------------------------------------- /125.valid-palindrome.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isPalindrome(self, s: str) -> bool: 3 | return [c for c in s.lower() if c.isalnum()] == [c for c in s.lower()[::-1] if c.isalnum()] 4 | -------------------------------------------------------------------------------- /7.reverse.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def reverse(self, x: int) -> int: 3 | return (lambda n: n if -(1<<31) <= n <= (1<<31) - 1 else 0)(int(str(x)[::-1]) if x >= 0 else -int(str(-x)[::-1])) -------------------------------------------------------------------------------- /70.climb-stairs.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def climbStairs(self, n: int) -> int: 3 | return round(math.sqrt(5) / 5 * (((1 + math.sqrt(5)) / 2) ** (n + 1) - ((1 - math.sqrt(5)) / 2) ** (n + 1))) -------------------------------------------------------------------------------- /122.best-time-to-buy-and-sell-stock-ii.pysubmissions: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxProfit(self, prices: List[int]) -> int: 3 | return sum(p2 - p1 for p1, p2 in zip(prices, prices[1:]) if p2 > p1) 4 | -------------------------------------------------------------------------------- /121.best-time-to-buy-and-sell-stock.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxProfit(self, prices: List[int]) -> int: 3 | return 0 if not prices else (bottom := inf, max(p - (bottom := min(bottom, p)) for p in prices))[-1] 4 | -------------------------------------------------------------------------------- /27.remove-element.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def removeElement(self, nums: List[int], val: int) -> int: 3 | return (lambda nums, nums_copy: [nums.clear(), len([nums.append(i) for i in nums_copy if i != val])][1])(nums, nums.copy()) -------------------------------------------------------------------------------- /141.linked-list-cycle.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def hasCycle(self, head: ListNode) -> bool: 3 | return False if head is None else True if (head.val == 'foobar', head.__setattr__('val', 'foobar'))[0] else self.hasCycle(head.next) 4 | -------------------------------------------------------------------------------- /26.remove-duplicates.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def removeDuplicates(self, nums: List[int]) -> int: 3 | return (lambda nums, unique_nums: [nums.clear(), len([nums.append(i) for i in unique_nums])][1])(nums, sorted(list(set(nums)))) 4 | -------------------------------------------------------------------------------- /1.two-sum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def twoSum(self, nums: List[int], target: int) -> List[int]: 3 | return (lambda nums, s: [[i, s[target - n]] for i, n in enumerate(nums) if target - n in s][0])(nums, {n: i for i, n in enumerate(nums)}) -------------------------------------------------------------------------------- /88.merge.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: 3 | """ 4 | Do not return anything, modify nums1 in-place instead. 5 | """ 6 | nums1[:] = sorted(nums1[: m] + nums2[: n]) -------------------------------------------------------------------------------- /119.pascals-triangle-ii.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def getRow(self, rowIndex: int) -> List[int]: 3 | return [1] if rowIndex == 0 else (lambda row: [1 if i == 0 or i == rowIndex else row[i - 1] + row[i] for i in range(rowIndex + 1)])(self.getRow(rowIndex - 1)) 4 | -------------------------------------------------------------------------------- /6121.query-kth-smallest-trimmed-number.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def smallestTrimmedNumbers(self, nums: List[str], queries: List[List[int]]) -> List[int]: 3 | return [sorted(list(map(lambda s: (int(s[1][-trim:]), s[0]), enumerate(nums))))[k - 1][1] for k, trim in queries] 4 | -------------------------------------------------------------------------------- /118.pascals-triangle: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def generate(self, numRows: int) -> List[List[int]]: 3 | return [] if numRows == 0 else (lambda matrix: (matrix.append([1 if i == 0 or i == numRows - 1 else matrix[-1][i - 1] + matrix[-1][i] for i in range(numRows)]), matrix))(self.generate(numRows - 1))[-1] 4 | -------------------------------------------------------------------------------- /14.longest-common-prefix.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def longestCommonPrefix(self, strs: List[str]) -> str: 3 | return (lambda f, *args: f(f, *args))(lambda f, strs: strs[0] if len(strs) == 1 else f(f, strs[: -2] + [strs[-1][: [a == b for a, b in zip(strs[-1] + '&', strs[-2] + '#')].index(False)]]), strs) if strs else "" -------------------------------------------------------------------------------- /111.minimum-depth-of-binary-tree.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minDepth(self, root: TreeNode) -> int: 3 | return 0 if root is None else 1 if root.left is None and root.right is None else min(self.minDepth(root.left) if root.left is not None else inf, self.minDepth(root.right) if root.right is not None else inf) + 1 4 | -------------------------------------------------------------------------------- /13.roman-to-int.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def romanToInt(self, s: str) -> int: 3 | return sum({'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}[c] for c in s) + sum(collections.defaultdict(lambda: 0, {'IV': -2, 'IX': -2, 'XL': -20, 'XC': -20, 'CD': -200, 'CM': -200})[c1 + c2] for c1, c2 in zip(s, s[1:])) 4 | -------------------------------------------------------------------------------- /6122.minimum-deletions-to-make-array-divisible: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def minOperations(self, nums: List[int], numsDivide: List[int]) -> int: 3 | return (lambda gcd: (lambda ans: -1 if ans == math.inf else ans)(min((i if gcd % n == 0 else math.inf) for i, n in enumerate(sorted(nums)))))(functools.reduce(math.gcd, numsDivide, numsDivide[0])) 4 | -------------------------------------------------------------------------------- /112.path-sum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def hasPathSum(self, root: TreeNode, sum: int) -> bool: 3 | return False if root is None else (lambda f, *args: f(f, *args))((lambda f, root, sum: (root is not None) and ((root.left is None and root.right is None and sum == root.val) or (f(f, root.left, sum - root.val)) or (f(f, root.right, sum - root.val)))), root, sum) 4 | -------------------------------------------------------------------------------- /104.max-depth.py: -------------------------------------------------------------------------------- 1 | # Definition for a binary tree node. 2 | # class TreeNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.left = None 6 | # self.right = None 7 | 8 | class Solution: 9 | def maxDepth(self, root: TreeNode) -> int: 10 | return 0 if root is None else max(self.maxDepth(root.left), self.maxDepth(root.right)) + 1 11 | -------------------------------------------------------------------------------- /160.intersection-of-two-linked-lists.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: 3 | return (checker := (lambda head, s: None if head is None else head if id(head) in s else checker(head.next, s)))(headB, (collector := (lambda head: set() if head is None else ((s := collector(head.next)).add(id(head)), s)[-1]))(headA)) 4 | -------------------------------------------------------------------------------- /20.is-valid.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isValid(self, s: str) -> bool: 3 | return (lambda f, *args: f(f, *args))(lambda f, stack, s:(f(f, stack + [s[0]], s[1:]) if s[0] in ['{', '[', '('] else (False if not stack else (f(f, stack[: -1], s[1:]) if s[0] == ']' and stack[-1] == '[' or s[0] == ')' and stack[-1] == '(' or s[0] == '}' and stack[-1] == '{' else False))) if s else not stack, [], s) -------------------------------------------------------------------------------- /53.max-sub-array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxSubArray(self, nums: List[int]) -> int: 3 | return (lambda max_sub_array, *args: max_sub_array(max_sub_array, *args))(lambda max_sub_array, index, cur_sum, max_sum: max_sum if index == len(nums) else max_sub_array(max_sub_array, index + 1, 0 if (next_sum := cur_sum + nums[index]) < 0 else next_sum, max(max_sum, next_sum)), 0, 0, 0) if (max_num := max(nums)) >= 0 else max_num -------------------------------------------------------------------------------- /66.plus-one.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def plusOne(self, digits: List[int]) -> List[int]: 3 | return (final_ans if (final_ans := (lambda plus_one, *args: plus_one(plus_one, *args))(lambda plus_one, index, ans: ans if ans.append((last := ans.pop()) % 10) or ans.append(last // 10 + (digits[index] if index != -1 else 0)) or index == -1 else plus_one(plus_one, index - 1, ans), len(digits) - 1, [10])[1:])[-1] else final_ans[: -1])[::-1] -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * Leetcode in One Line with Python 2 | 3 | I want to solve Leetcode problems in one line with python. That's it. 4 | 5 | ** Restrictions 6 | - One line means "one expression", which means I'm not going to use ";" combining multiple lines into one. 7 | - "exec" is not allowed so that I can't pack multiple expressions into an "exec" call. 8 | 9 | If you have a solution better than mine, please feel free to report an issue, or start a PR. 10 | -------------------------------------------------------------------------------- /110.is-balanced.py: -------------------------------------------------------------------------------- 1 | # Definition for a binary tree node. 2 | # class TreeNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.left = None 6 | # self.right = None 7 | 8 | class Solution: 9 | def isBalanced(self, root: TreeNode) -> bool: 10 | return (lambda f, *a: f(f, *a))(lambda check, root: 0 if not root else ((lambda x, y: max(x, y) + 1 if ~x and ~y and abs(x - y) <= 1 else -1)(check(check, root.left), check(check, root.right))), root) >= 0 11 | -------------------------------------------------------------------------------- /100.is-same-tree.py: -------------------------------------------------------------------------------- 1 | # Definition for a binary tree node. 2 | # class TreeNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.left = None 6 | # self.right = None 7 | 8 | class Solution: 9 | def isSameTree(self, p: TreeNode, q: TreeNode) -> bool: 10 | return (lambda same, *args: same(same, *args))(lambda same, a, b: True if a is b else False if type(a) is not type(b) or a.val != b.val else same(same, a.left, b.left) and same(same, a.right, b.right), p, q) -------------------------------------------------------------------------------- /662.maximum-width-of-binary-tree: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def widthOfBinaryTree(self, root: Optional[TreeNode]) -> int: 3 | return max(l[-1] - l[0] for l in (lambda record, solver: [solver((lambda dfs, record, node, depth, index: None if node is None else [dfs(dfs, record, node.left, depth + 1, index * 2), dfs(dfs, record, node.right, depth + 1, index * 2 + 1), record[depth].append(index)][0]), record, root, 0, 1), record][1])(collections.defaultdict(list), lambda func, *args: func(func, *args)).values()) + 1 4 | -------------------------------------------------------------------------------- /155.min-stack.py: -------------------------------------------------------------------------------- 1 | class MinStack: 2 | 3 | def __init__(self): 4 | """ 5 | initialize your data structure here. 6 | """ 7 | self.stack = [] 8 | 9 | def push(self, x: int) -> None: 10 | self.stack.append((x, min(self.stack[-1][1] if self.stack else inf, x))) 11 | 12 | def pop(self) -> None: 13 | self.stack.pop() 14 | 15 | def top(self) -> int: 16 | return self.stack[-1][0] 17 | 18 | def getMin(self) -> int: 19 | return self.stack[-1][1] 20 | -------------------------------------------------------------------------------- /21.merge-two-lists.py: -------------------------------------------------------------------------------- 1 | # Definition for singly-linked list. 2 | # class ListNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.next = None 6 | 7 | class Solution: 8 | def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: 9 | return (lambda merge, *args: merge(merge, *args)[0])(lambda merge, head1, head2: ((head2, head2.__setattr__('next', merge(merge, head1, head2.next)[0])) if head1.val >= head2.val else merge(merge, head2, head1)) if head1 and head2 else ((head1 or head2), None), l1, l2) -------------------------------------------------------------------------------- /101.is-symmetric.py: -------------------------------------------------------------------------------- 1 | # Definition for a binary tree node. 2 | # class TreeNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.left = None 6 | # self.right = None 7 | 8 | class Solution: 9 | def isSymmetric(self, root: TreeNode) -> bool: 10 | return (lambda same, *args: same(same, *args))(lambda same, a, b: True if a is b else False if type(a) is not type(b) or a.val != b.val else same(same, a.left, b.right) and same(same, a.right, b.left), root.left, root.right) if root is not None else True -------------------------------------------------------------------------------- /83.delete-duplicates.py: -------------------------------------------------------------------------------- 1 | # Definition for singly-linked list. 2 | # class ListNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.next = None 6 | 7 | class Solution: 8 | def deleteDuplicates(self, head: ListNode) -> ListNode: 9 | return (lambda delete_duplicates, *args: delete_duplicates(delete_duplicates, *args))(lambda delete_duplicates, head: head if not head or not head.next else delete_duplicates(delete_duplicates, head.next) if head.val == head.next.val else [head, head.__setattr__('next', delete_duplicates(delete_duplicates, head.next))][0], head) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/emacs 3 | # Edit at https://www.gitignore.io/?templates=emacs 4 | 5 | ### Emacs ### 6 | # -*- mode: gitignore; -*- 7 | *~ 8 | \#*\# 9 | /.emacs.desktop 10 | /.emacs.desktop.lock 11 | *.elc 12 | auto-save-list 13 | tramp 14 | .\#* 15 | 16 | # Org-mode 17 | .org-id-locations 18 | *_archive 19 | 20 | # flymake-mode 21 | *_flymake.* 22 | 23 | # eshell files 24 | /eshell/history 25 | /eshell/lastdir 26 | 27 | # elpa packages 28 | /elpa/ 29 | 30 | # reftex files 31 | *.rel 32 | 33 | # AUCTeX auto folder 34 | /auto/ 35 | 36 | # cask packages 37 | .cask/ 38 | dist/ 39 | 40 | # Flycheck 41 | flycheck_*.el 42 | 43 | # server auth directory 44 | /server/ 45 | 46 | # projectiles files 47 | .projectile 48 | 49 | # directory configuration 50 | .dir-locals.el 51 | 52 | # network security 53 | /network-security.data 54 | 55 | 56 | # End of https://www.gitignore.io/api/emacs 57 | -------------------------------------------------------------------------------- /107.level-orderbottom.py: -------------------------------------------------------------------------------- 1 | # Definition for a binary tree node. 2 | # class TreeNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.left = None 6 | # self.right = None 7 | 8 | class Solution: 9 | def levelOrderBottom(self, root: TreeNode) -> List[List[int]]: 10 | return (lambda level_order_bottom, *args: level_order_bottom(level_order_bottom, *args))(lambda level_order_bottom, left, right, ans: ans if not True in (available := [i % 2 and right[i // 2] is not None or not i % 2 and left[i // 2] is not None for i in range(2 * len(left))]) else [ans.append([right[i // 2].val if i % 2 else left[i // 2].val for i in range(2 * len(left)) if available[i]]), level_order_bottom(level_order_bottom, [right[i // 2].left if i % 2 else left[i // 2].left for i in range(2 * len(left)) if available[i]], [right[i // 2].right if i % 2 else left[i // 2].right for i in range(2 * len(left)) if available[i]], ans)][-1], [root.left], [root.right], [[root.val]])[::-1] if root is not None else [] -------------------------------------------------------------------------------- /38.count-and-say.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def countAndSay(self, n: int) -> str: 3 | return {1: "1", 2: "11", 3: "21", 4: "1211", 5: "111221", 6: "312211", 7: "13112221", 8: "1113213211", 9: "31131211131221", 10: "13211311123113112211", 11: "11131221133112132113212221", 12: "3113112221232112111312211312113211", 13: "1321132132111213122112311311222113111221131221", 14: "11131221131211131231121113112221121321132132211331222113112211", 15: "311311222113111231131112132112311321322112111312211312111322212311322113212221", 16: "132113213221133112132113311211131221121321131211132221123113112221131112311332111213211322211312113211", 17: "11131221131211132221232112111312212321123113112221121113122113111231133221121321132132211331121321231231121113122113322113111221131221", 18: "31131122211311123113321112131221123113112211121312211213211321322112311311222113311213212322211211131221131211132221232112111312111213111213211231131122212322211331222113112211", 19: "1321132132211331121321231231121113112221121321132122311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213122112311311123112111331121113122112132113213211121332212311322113212221", 20: "11131221131211132221232112111312111213111213211231132132211211131221131211221321123113213221123113112221131112311332211211131221131211132211121312211231131112311211232221121321132132211331121321231231121113112221121321133112132112312321123113112221121113122113121113123112112322111213211322211312113211", 21: "311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122211311122122111312211213211312111322211213211321322113311213212322211231131122211311123113223112111311222112132113311213211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221131112311311121321122112132231121113122113322113111221131221", 22: "132113213221133112132123123112111311222112132113311213211231232112311311222112111312211311123113322112132113213221133122112231131122211211131221131112311332211211131221131211132221232112111312111213322112132113213221133112132113221321123113213221121113122123211211131221222112112322211231131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122211211133112111311222112111312211312111322211213211321322113311213211331121113122122211211132213211231131122212322211331222113112211", 23: "111312211312111322212321121113121112131112132112311321322112111312212321121113122112131112131221121321132132211231131122211331121321232221121113122113121113222123112221221321132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322212321121113122123211231131122113221123113221113122112132113213211121332212311322113212221", 24: "3113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213213211221113122113121113222112132113213221232112111312111213322112132113213221133112132123123112111311222112132113311213211221121332211231131122211311123113321112131221123113112221132231131122211211131221131112311332211213211321223112111311222112132113212221132221222112112322211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211132221121311121312211213211312111322211213211321322113311213212322211231131122211311123113321112131221123113112211121312211213211321222113222112132113223113112221121113122113121113123112112322111213211322211312113211", 25: "132113213221133112132123123112111311222112132113311213211231232112311311222112111312211311123113322112132113212231121113112221121321132132211231232112311321322112311311222113111231133221121113122113121113221112131221123113111231121123222112132113213221133112132123123112111312111312212231131122211311123113322112111312211312111322111213122112311311123112112322211211131221131211132221232112111312111213111213211231132132211211131221232112111312212221121123222112132113213221133112132123123112111311222112132113213221132213211321322112311311222113311213212322211211131221131211221321123113213221121113122113121132211332113221122112133221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112212211131221121321131211132221123113112221131112311332211211133112111311222112111312211311123113322112111312211312111322212321121113121112133221121321132132211331121321231231121113112221121321132122311211131122211211131221131211322113322112111312211322132113213221123113112221131112311311121321122112132231121113122113322113111221131221", 26: "1113122113121113222123211211131211121311121321123113213221121113122123211211131221121311121312211213211321322112311311222113311213212322211211131221131211221321123113213221121113122113121113222112131112131221121321131211132221121321132132211331121321232221123113112221131112311322311211131122211213211331121321122112133221121113122113121113222123211211131211121311121321123113111231131122112213211321322113311213212322211231131122211311123113223112111311222112132113311213211221121332211231131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122113221122112133221121113122113121113222123211211131211121311121321123113213221121113122113121113222113221113122113121113222112132113213221232112111312111213322112311311222113111221221113122112132113121113222112311311222113111221132221231221132221222112112322211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331121321232221123123211231132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312111213111213211231132132211211131221131211221321123113213221123113112221131112211322212322211231131122211322111312211312111322211213211321322113311213211331121113122122211211132213211231131122212322211331222113112211", 27: "31131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122211211133112111311222112111312211312111322211213211321322123211211131211121332211231131122211311122122111312211213211312111322211231131122211311123113322112111331121113112221121113122113111231133221121113122113121113222123211211131211121332211213211321322113311213211322132112311321322112111312212321121113122122211211232221123113112221131112311332111213122112311311123112111331121113122112132113311213211321222122111312211312111322212321121113121112133221121321132132211331121321132213211231132132211211131221232112111312212221121123222112132113213221133112132123123112111311222112132113311213211231232112311311222112111312211311123113322112132113212231121113112221121321132122211322212221121123222112311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122211311123113322113223113112221131112311332211211131221131211132211121312211231131112311211232221121321132132211331221122311311222112111312211311123113322112132113213221133122211332111213112221133211322112211213322112111312211312111322212321121113121112131112132112311321322112111312212321121113122112131112131221121321132132211231131122211331121321232221121113122113121122132112311321322112111312211312111322211213111213122112132113121113222112132113213221133112132123222112311311222113111231132231121113112221121321133112132112211213322112111312211312111322212311222122132113213221123113112221133112132123222112111312211312111322212321121113121112133221121311121312211213211312111322211213211321322123211211131211121332211213211321322113311213212312311211131122211213211331121321122112133221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311222113111221221113122112132113121113222112132113213221133122211332111213322112132113213221132231131122211311123113322112111312211312111322212321121113122123211231131122113221123113221113122112132113213211121332212311322113212221", 28: "13211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331121321232221123123211231132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221232112111312211312113211223113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211322113321132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321322113311213212322211322132113213221133112132123222112311311222113111231132231121113112221121321133112132112211213322112111312211312111322212311222122132113213221123113112221133112132123222112111312211312111322212311322123123112111321322123122113222122211211232221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112212211131221121321131211132221123113112221131112311332211211133112111311222112111312211311123113322112111312211312111322212321121113121112133221121321132132211331121321132213211231132132211211131221232112111312212221121123222112311311222113111231133211121321321122111312211312111322211213211321322123211211131211121332211231131122211311123113321112131221123113111231121123222112111331121113112221121113122113111231133221121113122113121113221112131221123113111231121123222112111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321133112132112312321123113112221121113122113111231133221121321132132211331221122311311222112111312211311123113322112111312211312111322212311322123123112112322211211131221131211132221132213211321322113311213212322211231131122211311123113321112131221123113112211121312211213211321222113222112132113223113112221121113122113121113123112112322111213211322211312113211", 29: "11131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211132221121311121312211213211312111322211213211321322113311213212322211231131122211311123113223112111311222112132113311213211221121332211211131221131211132221231122212213211321322112311311222113311213212322211211131221131211132221232112111312111213322112131112131221121321131211132221121321132132212321121113121112133221121321132132211331121321231231121113112221121321133112132112211213322112311311222113111231133211121312211231131122211322311311222112111312211311123113322112132113212231121113112221121321132122211322212221121123222112111312211312111322212321121113121112131112132112311321322112111312212321121113122112131112131221121321132132211231131122111213122112311311222113111221131221221321132132211331121321231231121113112221121321133112132112211213322112311311222113111231133211121312211231131122211322311311222112111312211311123113322112132113212231121113112221121321132122211322212221121123222112311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122111213122112311311222112111331121113112221121113122113121113222112132113213221232112111312111213322112311311222113111221221113122112132113121113222112311311222113111221132221231221132221222112112322211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312111322212321121113121112133221132211131221131211132221232112111312111213322112132113213221133112132113221321123113213221121113122123211211131221222112112322211231131122211311123113321112132132112211131221131211132221121321132132212321121113121112133221123113112221131112311332111213211322111213111213211231131211132211121311222113321132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331121321232221123123211231132132211231131122211331121321232221123113112221131112311332111213122112311311123112112322211211131221131211132221232112111312211322111312211213211312111322211231131122111213122112311311221132211221121332211213211321322113311213212312311211131211131221223113112221131112311332211211131221131211132211121312211231131112311211232221121321132132211331121321231231121113112221121321133112132112211213322112312321123113213221123113112221133112132123222112311311222113111231132231121113112221121321133112132112211213322112311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122111213122112311311221132211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221133112132123222112111312211312111322212311222122132113213221123113112221133112132123222112311311222113111231133211121321132211121311121321122112133221123113112221131112311332211322111312211312111322212321121113121112133221121321132132211331121321231231121113112221121321132122311211131122211211131221131211322113322112111312211322132113213221123113112221131112311311121321122112132231121113122113322113111221131221", 30: "3113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112212211131221121321131211132221123113112221131112311332211211133112111311222112111312211311123113322112111312211312111322212321121113121112133221121321132132211331121321132213211231132132211211131221232112111312212221121123222112311311222113111231133211121321321122111312211312111322211213211321322123211211131211121332211231131122211311123113321112131221123113111231121123222112111331121113112221121113122113111231133221121113122113121113221112131221123113111231121123222112111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321132132211322132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211322113321132211221121332211231131122211311123113321112131221123113111231121113311211131221121321131211132221123113112211121312211231131122211211133112111311222112111312211312111322211213211321223112111311222112132113213221133122211311221122111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321132132211322132113213221123113112221133112132123222112111312211312112213211231132132211211131221131211322113321132211221121332211213211321322113311213212312311211131122211213211331121321123123211231131122211211131221131112311332211213211321223112111311222112132113213221123123211231132132211231131122211311123113322112111312211312111322111213122112311311123112112322211213211321322113312211223113112221121113122113111231133221121321132132211331222113321112131122211332113221122112133221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213122112311311123112112322211322311311222113111231133211121312211231131112311211232221121113122113121113222123211211131221132211131221121321131211132221123113112211121312211231131122113221122112133221121321132132211331121321231231121113121113122122311311222113111231133221121113122113121113221112131221123113111231121123222112132113213221133112132123123112111312211322311211133112111312211213211311123113223112111321322123122113222122211211232221121113122113121113222123211211131211121311121321123113213221121113122123211211131221121311121312211213211321322112311311222113311213212322211211131221131211221321123113213221121113122113121113222112131112131221121321131211132221121321132132211331121321232221123113112221131112311322311211131122211213211331121321122112133221121113122113121113222123112221221321132132211231131122211331121321232221121113122113121113222123211211131211121332211213111213122112132113121113222112132113213221232112111312111213322112132113213221133112132123123112111311222112132113311213211221121332211231131122211311123113321112131221123113112221132231131122211211131221131112311332211213211321223112111311222112132113212221132221222112112322211211131221131211132221232112111312111213111213211231131112311311221122132113213221133112132123222112311311222113111231132231121113112221121321133112132112211213322112111312211312111322212321121113121112131112132112311321322112111312212321121113122122211211232221121311121312211213211312111322211213211321322123211211131211121332211213211321322113311213211322132112311321322112111312212321121113122122211211232221121321132132211331121321231231121113112221121321133112132112312321123113112221121113122113111231133221121321132122311211131122211213211321222113222122211211232221123113112221131112311332111213122112311311123112111331121113122112132113121113222112311311221112131221123113112221121113311211131122211211131221131211132221121321132132212321121113121112133221123113112221131112311332111213213211221113122113121113222112132113213221232112111312111213322112132113213221133112132123123112111312211322311211133112111312212221121123222112132113213221133112132123222113223113112221131112311332111213122112311311123112112322211211131221131211132221232112111312111213111213211231132132211211131221131211221321123113213221123113112221131112211322212322211231131122211322111312211312111322211213211321322113311213211331121113122122211211132213211231131122212322211331222113112211"}[n] 4 | --------------------------------------------------------------------------------